/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.geaSV.actualizaciones;
import com.geaSV.entities.ProveedorE;
import java.util.List;  
import javax.faces.model.ListDataModel;   
import org.primefaces.model.SelectableDataModel;  
  
public class CarDataModel extends ListDataModel<ProveedorE> implements SelectableDataModel<ProveedorE> {    
  
    public CarDataModel() {  
    }  
  
    public CarDataModel(List<ProveedorE> data) {  
        super(data);  
    }  
      
    @Override  
    public ProveedorE getRowData(String rowKey) {  
        //In a real app, a more efficient way like a query by rowKey should be implemented to deal with huge data  
          
        List<ProveedorE> cars = (List<ProveedorE>) getWrappedData();  
          
        for(ProveedorE car : cars) {  
            if(car.getNombre().equals(rowKey))  
                return car;  
        }  
          
        return null;  
    }  
  
    @Override  
    public Object getRowKey(ProveedorE car) {  
        return car.getNombre();  
    }  
}  